<!DOCTYPE html>
<html>
<head>
<title> 挖一下，密码重置 Powered By PHPKind</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- 使用QLib控件是必须包含样式表 -->
<link rel="stylesheet" type="text/css" href="{$app:qlib/}/ui.css" />
<link rel="stylesheet" type="text/css" href="{$themes:path/}/all.css" />
<link rel="stylesheet" type="text/css" href="{$themes:path/}/style.css" />
<link rel="stylesheet" type="text/css" href="{$themes:path/}/registeruser.css" />

<script src="{$app:qlib}/Q.js">
<!--
import utils.stl;
import utils.json2;
import utils.ajax;
//-->
</script>
<script>
<!--
var page_is_valid = '{$fields:valid}'=='true'?true:false;

var err_info = {};
err_info[-1] = '验证码不能为空';
err_info[-2] = '用户名不能为空';
err_info[-3] = '输入密码不能为空';
err_info[-4] = '两次输入密码不一致';
err_info[-5] = '用户名非法';
err_info[-6] = '验证码已经过期或者作废，请重新申请';

Q.Ready(function(){

if(!page_is_valid) {
  Q.$('panel-1').style.display = 'none';
  Q.$('panel-2').style.display = '';
} else {
  Q.$('panel-2').style.display = 'none';
}

Q.$('reset-pwd').onclick = function() {
  var pwd = Q.$('pwd').value;
  var repwd = Q.$('repwd').value;
  var authkey = Q.$('authkey').value;
  var username = Q.$('username').value;
  if(!pwd || !repwd ) {
    error('输入密码不能为空');
	return;
  }

  if(pwd!=repwd) {
    error('两次输入的密码不一致!');
	return;
  }

  Q.Ajax({
    command: '{$app:module}&action=do-change-pwd&inajax=true',
	data : { pwd:pwd, repwd:repwd, authkey:authkey, username:username},
	oncomplete : function(xmlhttp) {
	  try {
		var resp = eval('('+xmlhttp.responseText+')');
		if(resp.header != 0) {
		  if(err_info[resp.header]) {
		    error(err_info[resp.header]);
		  } else {
		    error('未知错误');
		  }
		  
		} else {
		  alert('恭喜，密码修改成功!');
		  location.href = "{$app:module}&action=login";
		}
	  } catch (e) {
        error(xmlhttp.responseText);
	  }
	}
  });
}

});

var alpha_object = new alpha();

function error(msg) {
  Q.$("error").style.opacity = 1;
  Q.$("error").innerHTML = msg;
  setTimeout(function() {
	alpha_object.push(Q.$("error"));
	alpha_object.play();
  }, 3000); 
}

function alpha() {
  var _this = this;

  this.data = [];
  this.play = function() {
	if(_this.data.length == 0) {
	   return;
	}
	e = _this.data[0];
	var op = parseFloat(e.style.opacity, 10);
	op = op - 0.1;
	if(op >= 0.1) {
	  e.style.opacity = op;
	} else {
	  e.style.opacity = 0.0;
	  _this.data.shift();
	}
	setTimeout(function() { _this.play();}, 40);
  }

  this.push = function(e) {
    
	_this.data.push(e);
  }

  this.completed = function() {return _this.data.length == 0; };
}

//-->
</script>

</head>

<body>
<div class="regtop">
	<ul>
		<li><a href="{$app:app}">首页</a></li>
		<li><a href="{$app:app}&mod=user&action=register">注册</a></li>
		<li><a href="{$app:app}&mod=user&action=login">登录</a></li>
	</ul>
</div>
<div class="regtitle">
	<strong>密码重置</strong>
</div>
<div class="regmain" style="height:300px;" id="panel-1">
<input id="username" type=hidden value="{$get:u/}" size="50"/>
验证码：<br/><br/>
<input disabled id="authkey" type=text value="{$get:authkey/}" size="50"/>
<br/><br/>
请输入新密码：<br/><br/>
<input id="pwd" type=text value="" />
<br/><br/>
确认新密码: <br/><br/>
<input id="repwd" type=text value="" />
<br/><br/>
<button id="reset-pwd"> 重 置 </button>
<br/><br/>
<!-- error msg -->
<div id="error" style="border:1px solid #EEE;line-height:30px;text-indent:5px;color:red;"></div>
</div>
</div>
<div class="regmain" style="height:300px;" id="panel-2">
验证码已过期或无效，请重新申请!
</div>

<!--用户中心底部-->
<div class="footer">
	<span class="copyright">Powered by <a href="http://wayixia.com">wayixia.com</a> Copyright &copy;2013-2015 </span>
</div>
<!--//用户中心底部-->

</body>
</html>
